home *** CD-ROM | disk | FTP | other *** search
/ Network Supervisor's Toolkit / Network Supervisor's Toolkit.iso / tools / nwtp06 / tstent2.pas < prev    next >
Pascal/Delphi Source File  |  1996-07-10  |  4KB  |  138 lines

  1. Program tstent2;
  2.  
  3. { Testprogram for the nwFile unit / NwTP 0.6 API. (c) 1993,1995, R.Spronk }
  4.  
  5. { Tests the following nwFile calls:
  6.  
  7.   GetDirectoryEntry
  8.   ScanDirectoryInformation
  9.   ScanFileInformation
  10.   ScanSalvagableFiles
  11. }
  12.  
  13. uses nwMisc,nwBindry,nwFile;
  14.  
  15.  
  16. Procedure PrintEntry(e:Tentry);
  17. VAr s,ObjName:String;
  18.     ObjType:Word;
  19. begin
  20. with e
  21.  do begin
  22.     writeln('----------------------------------');
  23.     writeln('Name:',EntryName);
  24.     writeln('FileSize       :',FileSize);
  25.     writeln('Name space     :',NStype);
  26.     writeln('Data fork size :',DataForkSize);
  27.     writeln;
  28.     writeln('Attributes:',HexStr(Attributes,8));
  29.     writeln('RightsMask:',HexStr(RightsMask,4));
  30.     writeln;
  31.  
  32.     objName:='';
  33.     NovTime2String(CreationTime,s);
  34.     GetBinderyObjectName(OwnerId,ObjName,ObjType);
  35.     writeln('Created at       :',s,' by ',ObjName,' (',HexStr(OwnerId,8),')');
  36.  
  37.     objName:='';
  38.     NovTime2String(ArchiveTime,s);
  39.     GetBinderyObjectName(ArchiverId,ObjName,ObjType);
  40.     writeln('Last archived at :',s,' by ',ObjName,' (',HexStr(ArchiverId,8),')');
  41.  
  42.     objName:='';
  43.     NovTime2String(ModifyTime,s);
  44.     GetBinderyObjectName(ModifierId,ObjName,ObjType);
  45.     writeln('Last modified at :',s,' by ',ObjName,' (',HexStr(ModifierId,8),')');
  46.  
  47.     NovTime2String(LastAccessTime,s);
  48.     writeln('Last accessed at :',s);
  49.  
  50.     objName:='';
  51.     NovTime2String(DeleteTime,s);
  52.     GetBinderyObjectName(DeletorId,ObjName,ObjType);
  53.     writeln('Deleted at       :',s,' by ',ObjName,' (',HexStr(DeletorId,8),')');
  54.     writeln;
  55.   end;
  56. end;
  57.  
  58. Var DirHandle,EffRights:Byte;
  59.     DirEntry:Tentry;
  60.     SearchFlags,EntryId:Longint;
  61.     PathNAme:STring;
  62.     SeqNbr:Integer;
  63.     WseqNbr:word;
  64.  
  65. begin
  66.  
  67. AllocPermanentDirHandle(7,0,'SYS:PUBLIC',DirHandle,EffRights);
  68.  
  69. writeln;
  70. writeln('Test of GetDirectoryEntry (get entry SYS:\PUBLIC');
  71. write('<RETURN> to contimue...');
  72. readln;
  73.  
  74. IF GetDirectoryEntry(dirHandle,dirEntry)
  75.  then PrintEntry(dirEntry)
  76.  else writeln('Error using GetDirectoryEntry, err#',nwFile.result);
  77.  
  78. SetDirectoryHandle(0,'SYS:',DirHandle);
  79.  
  80. GetDirectoryPAth(DirHandle,PathNAme);
  81. writeln('handle ass. with:',PathName);
  82.  
  83. writeln;
  84. writeln('Test of ScanDirectoryInformation (scan subdirs of SYS:\PUBLIC');
  85. write('<RETURN> to contimue...');
  86. readln;
  87.  
  88. WseqNbr:=0;
  89. while ScanDirectoryInformation(dirHandle,'PUBLIC\*',WseqNbr,dirEntry)
  90.  do begin
  91.     writeln('SeqNbr now is: ',WseqNbr);
  92.     PrintEntry(DirEntry);
  93.     end;
  94. if nwFile.result<>$9C
  95.  then writeln('error using ScanDirInfo :',nwFile.result);
  96.  
  97.  
  98. writeln;
  99. writeln('Test of ScanFileInformation (scan *.EXE files in SYS:\PUBLIC');
  100. write('<RETURN> to contimue...');
  101. readln;
  102.  
  103. seqNbr:=-1;
  104. while ScanFileInformation(DirHandle,'PUBLIC\*.EXE',
  105.                           $FF,
  106.                           SeqNbr,
  107.                           dirEntry)
  108.  do begin
  109.     PrintEntry(DirEntry);
  110.     end;
  111. if nwFile.result<>$FF
  112.  then writeln('error using ScanFileInfo :',nwFile.result);
  113.  
  114.  
  115. writeln;
  116. writeln('Test of ScanSalvagableFiles (erased files in SYS:\PUBLIC');
  117. write('<RETURN> to contimue...');
  118. readln;
  119.  
  120. SetDirectoryHandle(0,'SYS:\PUBLIC',DirHandle);
  121.  
  122.  
  123. EntryId:=-1;
  124. WHILE ScanSalvagableFiles(DirHandle,
  125.                           EntryId,
  126.                           dirEntry)
  127.  do begin
  128.     PrintEntry(dirEntry);
  129.     writeln('NextEntryId:',hexStr(entryId,8));
  130.     end;
  131. if nwFile.result<>$FF
  132.  then writeln('error using ScanSalvagable files :',nwFile.result);
  133.  
  134.  
  135. DeallocateDirHandle(DirHandle);
  136.  
  137.  
  138. end.